<!doctype html>
{% load static %}
<html lang="zh">
<head>
    <title>用户登录</title>
    <meta http-equiv="Content-Tyuserspe" content="text/html; charset=utf-8" />
    <link href="{% static 'css/style2.css' %}" rel='stylesheet' type='text/css' />
	<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
    <!-- js -->
    <script>window.jQuery || document.write('<script src="{% static 'js/jquery-2.1.1.min.js' %}"><\/script>')</script>
    <script src="{% static 'js/vidbg.js' %}"></script>
    <script type="text/javascript">
        jQuery(function($){
            $('body').vidbg({
                 'mp4': '{% static "images/mp4.mp4" %}',
            }, {
                // Options
                muted: true,
                loop: true,
                overlay: true,
            });
        });

        $(document).ready(function(){
                $(".loginButton").click(function(){
                    var username = $("#id_username").val();
                    var password = $("#id_password").val();
					console.log(username);
                    $.ajax({
                        type:"POST",
                        data:{'username':username, 'password':password,},
                        url:"{% url 'users:login' %}",
						
                        success:function(data){
                            console.log(data["st"]);

                            if(data["st"] === 1){
                                window.location.href="{% url 'index' %}";
                            }
                            else if(data["st"] === 2){
                                alert("用户已被锁定，请联系管理员恢复");
                                window.location.href="{% url 'users:login' %}";
                            }
                            else {
                                alert("登录失败，用户名或密码错误")
                                window.location.href="{% url 'users:login' %}";
                            }
                        },
                        error:function(){
                            alert("false");
                        }
                    })
                })
        })

    </script>
</head>
<body>
<div class="contain">
<h1><a href="{% url 'index' %}"style="color:white">DragonStack Cloud</a></h1>
<div class="main">


    <div class="login-top left">
        <div class="social_icons">
            <div class="w3-signup-head-top">
                <h3>用户登录</h3>
            </div>

        </div>
        <form>
            <input type="text" id="id_username"  name="username" class="name" placeholder="Name" required=""/>
            <input type="password" id="id_password" name="password" class="password" placeholder="Password" required=""/>
            <input type="button" class="loginButton" id="logbtn" value="登录"/>
        </form>
        <div class="w3-bottom-text">
            <h3><a href="{% url 'users:forget' %}">忘记密码<span>?</span></a></h3>
            <h4><a href="{% url 'users:regist' %}">注册</a></h4>

        </div>
        <div class="clear"></div>
    </div>


</div>
<div class="clear"></div>
<div class="copy-right w3l-agile logbotom">
    <p>Copyright © 2017 Provincial Key Laboratory of Network and System Security, Xidian University, Shaanxi Province, China.</p>
</div>

</div>
</body>
</html>